package com.example.earchartsspringweb.controller;

import com.example.earchartsspringweb.data.BarData;
import com.example.earchartsspringweb.data.LineData;
import com.example.earchartsspringweb.data.PieData;
import com.example.earchartsspringweb.service.BarDataService;
import com.example.earchartsspringweb.service.LineDataService;
import com.example.earchartsspringweb.service.PieDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class ChartDataController {

    @Autowired
    private PieDataService pieDataService;

    @Autowired
    private BarDataService barDataService;

    @Autowired
    private LineDataService lineDataService;

    @GetMapping("/line-data")
    public ResponseEntity<List<LineData>> getLineData() {
        List<LineData> data = lineDataService.getAllLineData();
        return new ResponseEntity<>(data, HttpStatus.OK);
    }

    @GetMapping("/pie-data")
    public ResponseEntity<List<PieData>> getPieData() {
        List<PieData> data = pieDataService.getAllPieData();
        return new ResponseEntity<>(data, HttpStatus.OK);
    }

    @GetMapping("/bar-data")
    public ResponseEntity<List<BarData>> getBarData() {
        List<BarData> data = barDataService.getAllBarData();
        return new ResponseEntity<>(data, HttpStatus.OK);
    }
}